import { View } from "../../../mvc/core/View";
import { LayerManager } from "../../manager/LayerManager";
import { ObjCreate } from "../common/ObjCreate";
import { ResFileConst } from "../../resource/ResFileConst";
import { SecTimerView } from "../common/SecTimerView";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { Cache } from "../../cache/Cache";
import { EMarryStatus } from "../../../../Message/Game/EMarryStatus";
import { MsgManager } from "../../manager/MsgManager";
import { Language } from "../../../../extend/language/Language";
import { Alert } from "../../../../com/mui/controls/Alert";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
type int = number;
//class MarryDivorceIconView
    
    export  class MarryDivorceIconView extends View
    {
        constructor()
        {
            super();
            this.layer = LayerManager.rightTopUILayer;
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._divorceBtn = ObjCreate.createGLoadedButton(ResFileConst.MarryDivorceBtn, 0, 0, 50, 50, this);
            this._divorceBtn.configEventListener(flash.events.MouseEvent.CLICK, this.onDivorceBtnClick);
            this._leftTime = new SecTimerView();
            this._leftTime.setParse("HH: mm: ss");
            this._leftTime.mouseEnabled = false;
            var loc1=new GTextFormat(FontUtil.songtiName, 12, 16580352);
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._leftTime.defaultTextFormat = loc1;
            this._leftTime.filters = [FilterConst.glowFilter];
            ObjCreate.setObjAttri(this._leftTime, -15, 55, 80, 20, this);
            this._leftTime.mouseEnabled = false;
            return;
        }

        /* internal  */onDivorceBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=Cache.instance.marry.playerMarry;
            if (loc1) 
            {
                if (loc1.status == EMarryStatus._EMarryStatusApply) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(43656));
                }
                if (loc1.status == EMarryStatus._EMarryStatusBeApply) 
                {
                    Alert.yesLabel = Language.getString(43657);
                    Alert.noLabel = Language.getString(43658);
                    Alert.calcelLabel = Language.getString(43659);
                    Alert.buttonWidth = 70;
                    Alert.show(Language.getString(43660), null, Alert.YES | Alert.NO | Alert.CANCEL, null, this.onBeApplyDivorceSelect);
                }
            }
            return;
        }

        /* internal  */onBeApplyDivorceSelect(arg1: int): void
        {
            if (arg1 == Alert.CANCEL) 
            {
                return;
            }
            var loc1=arg1 == Alert.YES;
            Dispatcher.dispatchEvent(new DataEvent(EventName.MarryReplyDivorce, loc1));
            return;
        }

        public updateLeftTime(arg1: int): void
        {
            this._leftTime.setLeftTime(arg1);
            return;
        }

        /* internal */ /* var */_divorceBtn: GLoadedButton;

        /* internal */ /* var */_leftTime: SecTimerView;
    }
